package com.ticket.sass.admin.dto.output.resource;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.jetbrains.annotations.NotNull;

import java.util.List;

/**
 * @author ywb
 * @date 2022-01-07 16:21
 */
@Data
@ApiModel(value = "角色资源")
public class RoleResourceOutput implements Comparable<RoleResourceOutput> {
    @ApiModelProperty("资源ID")
    private Integer id;

    @ApiModelProperty("资源父ID")
    private Integer parentId;

    @ApiModelProperty("名字")
    private String name;

    @ApiModelProperty("排序")
    private Integer sort;

    @ApiModelProperty(value = "路由路径")
    private String path;
    @ApiModelProperty(value = "是否缓存")
    private String noCache;
    @ApiModelProperty(value = "组件")
    private String component;
    @ApiModelProperty(value = "是否显示")
    private String hidden;

    @ApiModelProperty(value = "权限标识符")
    private String perms;

    @ApiModelProperty(value = "元结构")
    private Meta meta;

    @ApiModelProperty("菜单资源")
    private List<RoleResourceOutput> children;

    public RoleResourceOutput() {
    }

    public RoleResourceOutput(Integer id, Integer parentId, String name, Integer sort, String perms) {
        this.id = id;
        this.parentId = parentId;
        this.name = name;
        this.sort = sort;
        this.perms = perms;
    }

    @Override
    public int compareTo(@NotNull RoleResourceOutput o) {
        return this.sort.compareTo(o.getSort());
    }

    @Data
    @AllArgsConstructor
    @ApiModel(value = "单独结构")
    public static class Meta {
        @ApiModelProperty(value = "标题")
        private String title;
        @ApiModelProperty(value = "图标")
        private String icon;
    }
}
